//
//  TWBUserAccountViewModel.swift
//  weiBo
//
//  Created by 杨雷 on 2016/12/12.
//  Copyright © 2016年 Yang.L. All rights reserved.
//

import UIKit

class TWBUserAccountViewModel: NSObject {
    
    static let sharedUserAccount: TWBUserAccountViewModel = TWBUserAccountViewModel()
    
    var userAccount: TWBUserAccount? {
        
        return TWBUserAccount.loadUserAccount()
    }
    
    var isLogin: Bool {
        
        return accessToken != nil
    }
    
    var accessToken: String? {
        
        guard let token = userAccount?.access_token else {
            return nil
        }
        if userAccount?.expiresDate?.compare(Date()) == ComparisonResult.orderedDescending {
            
            return token
            
        } else {
            
            return nil
        }
        
    }
    
    func requestAccessToken(code: String, callBack: (Bool) -> ()) {
        
        
    }
    
    
    
    
}
